package com.np.mvp1;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity implements IContract.View {
    private TextView tvNote;
    private ProgressBar mProgressBar;
    private IContract.Presenter mPresenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        this.tvNote = findViewById(R.id.textView);
        this.mProgressBar = findViewById(R.id.progressBar);
        findViewById(R.id.button).setOnClickListener(view -> mPresenter.onButtonClick());

        this.mPresenter = new Presenter(this, new Model());
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mPresenter.onDestroy();
    }

    @Override
    public void showProgress() {
        mProgressBar.setVisibility(View.VISIBLE);
        tvNote.setVisibility(View.INVISIBLE);
    }

    @Override
    public void hideProgress() {
        mProgressBar.setVisibility(View.GONE);
        tvNote.setVisibility(View.VISIBLE);
    }

    @Override
    public void showNote(String note) {
        tvNote.setText(note);
    }
}